<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>修改密码</title>
<script type="text/javascript">
	$(function() {
		$.extend($.fn.validatebox.defaults.rules, {
			equals : {
				validator : function(value, param) {
					return value == $(param[0]).val();
				},
				message : '二次的输入新密码不一致'
			}
		});
		/* 	$('#fm').form('submit', {    
				url : "${ctx}/basic/user/updatePassword",  
			    success:function(data){    
			    	$.messager.show({
						msg : data.msg,
						icon : "info",
						position : "bottomRight"
					});  
			    }    
			}); */
		$('#submit').bind('click', function(row) {
			var oldPassword = $("#oldPassword").val();
			var newPassword = $("#newPassword").val();
			var newPasswordA = $("#newPasswordA").val();
			if (oldPassword.length == 0 && newPassword == 0 && newPasswordA == 0) {
				return;
			}
			$("#oldPassword").val("");
			$("#newPassword").val("");
			$("#newPasswordA").val("");
			$.post("${ctx}/basic/user/updatePassword", {
				oldPassword : oldPassword,
				newPassword : newPassword,
				newPasswordA : newPasswordA
			}, function(data) {
				alert(data.msg);
			}, "json");

		});

		$('#reset').bind('click', function(row) {
			$("#oldPassword").val("");
			$("#newPassword").val("");
			$("#newPasswordA").val("");
		});

		/*$("#sumbit").click(
				function() {
					var oldPassword = $("#oldPassword").val();
					var newPassword = $("#newPassword").val();
					var newPasswordA = $("#newPasswordA").val();
					if (oldPassword.length == 0 && newPassword == 0
							&& newPasswordA == 0) {
						return;
					}
					$("#oldPassword").val("");
					$("#newPassword").val("");
					$("#newPasswordA").val("");
					$.post("${ctx}/basic/user/updatePassword", {
						oldPassword : oldPassword,
						newPassword : newPassword,
						newPasswordA : newPasswordA
					}, function(data) {
						alert(data.msg);
					}, "json");
				});*/

	});
</script>
</head>

<body>
	<div align="center">
		<div class="panel panel-primary"
			style="width: 500px; height: 350px; padding: 50px;" align="center">
			<div class="panel-heading" align="center">密码修改</div>

			<div class="panel-body" align="center" style="padding: 30px;">
				<form>
					<table class="table-condensed">
						<tr>
							<td><label>旧&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;码：</label></td>
							<td><input id="oldPassword" name="oldPassword"
								type="password" class="easyui-validatebox" required="required">
							</td>
						</tr>
						<tr>
							<td><label>新&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;码：</label></td>
							<td><input id="newPassword" name="newPassword"
								type="password" class="easyui-validatebox" required="required">
							</td>
						</tr>
						<tr>
							<td><label>请重复输入密码：</label></td>
							<td><input id="newPasswordA" name="newPasswordA"
								type="password" class="easyui-validatebox"
								validType="equals['#newPassword']" required="required"></td>
						</tr>
					</table>
				</form>
			</div>

			<div class="panel-footer" align="right">
				<button id="submit" class="btn btn-primary" type="button">
					<span class="glyphicon glyphicon-ok"></span> 提交
				</button>
				<button id="reset" class="btn btn-primary" type="button">
					<span class="glyphicon glyphicon-refresh"></span> 重置
				</button>
			</div>

		</div>
	</div>
</body>
</html>